%% Carbon Taxes Around the World: Cooperation, Strategic Interactions, and Spillovers
% IMF Economic Review
% Alessandro Moro and Valerio Nispi Landi
% Replication files
% This file plots the reaction functions

clc; clear all; close all
SAVE=0;
PAPER=1;       % PAPER=1: Figure for paper, PAPER=0, Figure for presentation
SYM=0;
LIN=1;
DAM=0;

load sim_psi0 
load sim_psi05
load sim_psi1

ne=[ne_psi0; ne_psi05; ne_psi1];
DG= 0.00:0.0001:0.007; 
if DAM==1
DG=10*DG;
end
    
G=length(DG);




usedfont='Georgia';
FigW=17;
FigH=FigW;

% Paper figure, symmetric calibration, non-linear tax

if PAPER==1 && SYM==1 && LIN==0 && DAM==0
figure;
set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);
plot(DG, reaction1_psi0(1:G),'b','Linewidth',2)
hold on
plot(DG, reaction1_psi05(1:G),'r:','Linewidth',2)
hold on
plot(DG, reaction1_psi1(1:G),'k--','Linewidth',2)
xlim([DG(1) DG(end)])
ylim([DG(1) DG(end)])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xlabel('ϝ^*','Fontsize',18,'fontweight','bold')
ylabel('Optimal ϝ','Fontsize',18,'fontweight','bold')
xticks([0:.002:.007])
yticks([0:.002:.007])

legend('\psi_X=0','\psi_X=0.5','\psi_X=1','Location','Northeast','Fontsize',14)   
if SAVE==1
print('-dpng','-r500',['./figures/reaction_dynamic.png'])
end

% Paper figure, asymmetric calibration, non-linear tax

elseif PAPER==1 && SYM==0 && LIN==0 && DAM==0
FigW=15;
FigH=10;
figure;
   set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);
subplot(1,2,1) 
plot(DG, reaction1_psi0(1:G),'b','Linewidth',2)
hold on
plot(DG, reaction1_psi05(1:G),'r:','Linewidth',2)
hold on
plot(DG, reaction1_psi1(1:G),'k--','Linewidth',2)
xlim([DG(1) .007])
ylim([DG(1) .007])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xticks([0:.002:.007])
yticks([0:.002:.007])

xlabel('ϝ^*','Fontsize',12,'fontweight','bold')
ylabel('Optimal ϝ','Fontsize',12,'fontweight','bold')
title('Optimal AE policy','Fontsize',12,'fontweight','bold')

subplot(1,2,2)    
plot(DG, reaction2_psi0(1:G),'b','Linewidth',2)
hold on
plot(DG, reaction2_psi05(1:G),'r:','Linewidth',2)
hold on
plot(DG, reaction2_psi1(1:G),'k--','Linewidth',2)
xlim([DG(1) .007])
ylim([DG(1) .007])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xticks([0:.002:.007])
yticks([0:.002:.007])
xlabel('ϝ','Fontsize',12,'fontweight','bold')
ylabel('Optimal ϝ^*','Fontsize',12,'fontweight','bold')
title('Optimal EME policy','Fontsize',12,'fontweight','bold')
leg=legend('\psi_X=0','\psi_X=0.5','\psi_X=1','Location','northeast','Fontsize',12);   
% leg.Position(1) = 0.35;
% leg.Position(2) = 0.01;
if SAVE==1
print('-dpng','-r500',['./figures/reaction_dynamic_asym.png'])
end

% Paper figure, asymmetric calibration, linear tax

elseif PAPER==1 && SYM==0 && LIN==1 && DAM==0
%DG=DG/10;
FigW=15;
FigH=10;
figure;
   set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);
subplot(1,2,1) 
plot(DG, 10*reaction1_psi0(1:G),'b','Linewidth',2)
hold on
plot(DG, 10*reaction1_psi05(1:G),'r:','Linewidth',2)
hold on
plot(DG, 10*reaction1_psi1(1:G),'k--','Linewidth',2)
xlim([DG(1) .005])
ylim([DG(1) .005])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xticks(0:.002:.005)
yticks(0:.002:.005)

xlabel('ϝ^*','Fontsize',12,'fontweight','bold')
ylabel('Optimal ϝ','Fontsize',12,'fontweight','bold')
title('Optimal AE policy','Fontsize',12,'fontweight','bold')

subplot(1,2,2)    
plot(DG, 10*reaction2_psi0(1:G),'b','Linewidth',2)
hold on
plot(DG, 10*reaction2_psi05(1:G),'r:','Linewidth',2)
hold on
plot(DG, 10*reaction2_psi1(1:G),'k--','Linewidth',2)
xlim([DG(1) .005])
ylim([DG(1) .005])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xticks(0:.002:.005)
yticks(0:.002:.005)
xlabel('ϝ','Fontsize',12,'fontweight','bold')
ylabel('Optimal ϝ^*','Fontsize',12,'fontweight','bold')
title('Optimal EME policy','Fontsize',12,'fontweight','bold')
leg=legend('\psi_X=0','\psi_X=0.5','\psi_X=1','Location','northeast','Fontsize',12);   
% leg.Position(1) = 0.35;
% leg.Position(2) = 0.01;
if SAVE==1
print('-dpng','-r500',['./figures/reaction_dynamic_asym_lin.png'])
end

% Paper figure, asymmetric calibration, higher damage

elseif PAPER==1 && SYM==0 && LIN==0 && DAM==1
%DG=DG/10;
FigW=15;
FigH=10;
figure;
   set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);
subplot(1,2,1) 
plot(DG, reaction1_psi0(1:G),'b','Linewidth',2)
hold on
plot(DG, reaction1_psi05(1:G),'r:','Linewidth',2)
hold on
plot(DG, reaction1_psi1(1:G),'k--','Linewidth',2)
xlim([DG(1) .04])
ylim([DG(1) .04])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xticks([0:.02:.07])
yticks([0:.02:.07])

xlabel('ϝ^*','Fontsize',12,'fontweight','bold')
ylabel('Optimal ϝ','Fontsize',12,'fontweight','bold')
title('Optimal AE policy','Fontsize',12,'fontweight','bold')

subplot(1,2,2)    
plot(DG, reaction2_psi0(1:G),'b','Linewidth',2)
hold on
plot(DG, reaction2_psi05(1:G),'r:','Linewidth',2)
hold on
plot(DG, reaction2_psi1(1:G),'k--','Linewidth',2)
xlim([DG(1) .07])
ylim([DG(1) .07])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xticks([0:.02:.07])
yticks([0:.02:.07])
xlabel('ϝ','Fontsize',12,'fontweight','bold')
ylabel('Optimal ϝ^*','Fontsize',12,'fontweight','bold')
title('Optimal EME policy','Fontsize',12,'fontweight','bold')
leg=legend('\psi_X=0','\psi_X=0.5','\psi_X=1','Location','northeast','Fontsize',12);   
% leg.Position(1) = 0.35;
% leg.Position(2) = 0.01;
if SAVE==1
print('-dpng','-r500',['./figures/reaction_dynamic_asym_dam.png'])
end

% Presentation figure, symmetric calibration, non-linear tax

elseif PAPER==0  && LIN==0 && DAM==0

FigW=15;
FigH=10;
figure;
   set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);
subplot(1,2,1) 
plot(DG, reaction1_psi0(1:G),'b','Linewidth',2)
hold on
% plot(DG, reaction1_psi05(1:G),'r:','Linewidth',2)
% hold on
plot(DG, reaction1_psi1(1:G),'r','Linewidth',2)
xlim([DG(1) .007])
ylim([DG(1) .007])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xticks([0:.002:.007])
yticks([0:.002:.007])

xlabel('ϝ^*','Fontsize',12,'fontweight','bold')
ylabel('Optimal ϝ','Fontsize',12,'fontweight','bold')
title('Optimal AE policy','Fontsize',12,'fontweight','bold')

subplot(1,2,2)    
plot(DG, reaction2_psi0(1:G),'b','Linewidth',2)
hold on
% plot(DG, reaction2_psi05(1:G),'r:','Linewidth',2)
% hold on
plot(DG, reaction2_psi1(1:G),'r','Linewidth',2)
xlim([DG(1) .007])
ylim([DG(1) .007])
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
ax.XAxis.Exponent = 0;
xticks([0:.002:.007])
yticks([0:.002:.007])
xlabel('ϝ','Fontsize',12,'fontweight','bold')
ylabel('Optimal ϝ^*','Fontsize',12,'fontweight','bold')
title('Optimal EME policy','Fontsize',12,'fontweight','bold')
leg=legend('\psi_X=0','\psi_X=1','Location','northeast','Fontsize',12);   
% leg.Position(1) = 0.35;
% leg.Position(2) = 0.01;
if SAVE==1
print('-dpng','-r500',['./figures/reaction_dynamic_pres.png'])
end
end
